local skel = fk.CreateSkill {
  name = "emo__huran",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__huran"] = "互染",
  [":emo__huran"] = "锁定技，你或有“兄”标记的角色的回合结束时，你选择令你与其分别执行：回复一点体力/将手牌摸至体力上限。",

  ["#emo__huran-choice"] = "互染：选择你和 %src 执行的内容",
  ["emo__huran_choice1"] = "我回复1点体力，“兄”摸牌至体力上限",
  ["emo__huran_choice2"] = "“兄”回复1点体力，我摸牌至体力上限",
}

skel:addEffect(fk.TurnEnd, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    local bro = player.room:getPlayerById(player:getMark("emo__weiyi_bro"))
    if player:hasSkill(skel.name) and bro and not bro.dead then
      event:setCostData(self, {tos = {bro} })
      return target == bro or target == player
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local bro = room:getPlayerById(player:getMark("emo__weiyi_bro"))
    local choices = {}
    if player:isWounded() or bro:getHandcardNum() < bro.maxHp then table.insert(choices, "emo__huran_choice1") end
    if bro:isWounded() or player:getHandcardNum() < player.maxHp then table.insert(choices, "emo__huran_choice2") end
    if #choices == 0 then return end
    local choice = room:askToChoice(player, { choices = choices, skill_name = skel.name, prompt = "#emo__huran-choice:"..bro.id})
    local recoverOne = choice:endsWith("1") and player or bro
    local drawOne = choice:endsWith("2") and player or bro
    if recoverOne:isWounded() and not recoverOne.dead then
      room:recover { num = 1, skillName = skel.name, who = recoverOne, recoverBy = player}
    end
    if drawOne:getHandcardNum() < drawOne.maxHp and not drawOne.dead then
      drawOne:drawCards(drawOne.maxHp - drawOne:getHandcardNum(), skel.name)
    end
  end,
})

return skel
